package com.elsa.smart_buffet.service.impl;

import com.elsa.smart_buffet.mapper.MenuOrderMapper;
import com.elsa.smart_buffet.pojo.MenuOrder;
import com.elsa.smart_buffet.pojo.ResultBox.CallBackMessage;
import com.elsa.smart_buffet.pojo.ResultBox.ResponseResult;
import com.elsa.smart_buffet.service.MenuOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName : MenuMapperServiceImpl  //类名
 * @Author : elsa //作者
 */
@Service
@Slf4j
@Transactional
public class MenuMapperServiceImpl implements MenuOrderService {

    @Autowired
    private MenuOrderMapper menuOrderMapper;

    @Override
    public ResponseResult selectMenuOrderMapperFromOrder(String oId) {
        List<MenuOrder> list = menuOrderMapper.selectMenuOrderMapperFromOrder(oId);
        String res = "";
        for (int i = 0; i < list.size(); i++) {
            if(i != list.size() - 1) {
                res += list.get(i).getMName() + ",";
            } else {
                res += list.get(i).getMName();
            }
        }
        log.info("订单号oId对应的菜品为" + res);
        return new ResponseResult(CallBackMessage.SUCCESS, res);
    }

}
